﻿<!DOCTYPE>

<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>退库申请单-查看</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style type="text/css">
        .linkbutton{margin-left:20px;min-width:85px;}
        table tr td{padding:0px 5px}
    </style>
</head>
<body>
      <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>订单号:</td>
	    			<td>物料编码:</td>
                    <td>物料名称:</td>
                    <td>批次序列号:</td>
                    <td>退库类型:</td>
                    <td>检验状态:</td>
                    <td>状态:</td>
	    		</tr>
	    		<tr>
                    <td><input class="easyui-textbox" type="text" name="MfgOrdername" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-textbox" type="text" name="productName" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-textbox" type="text" name="productDesc" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-textbox" type="text" name="containerNo" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-combobox" type="text" name="returnType" style="width: 120px; height: 22px" id="ReturnType"/></td>
                    <td><input id="checkStatus" name="checkStatus" style="width: 120px; height: 22px"/></td>
	    			<td><input id="STATUS" name="status" style="width: 120px; height: 22px"/></td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.searchReset()">重置</a></td>
                    <td></td>
	    		</tr>
	    	</table>
	    </form> 
        </div>
      </div>
      <div class="panelSection">    
        <div class="easyui-panel " title="退库申请" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <table id="StockReturnApplyTable" style="height:500px;width:100%"></table>
           <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]
                ">
                    </div>
        </div>
      </div>
      <div class="panelSection">    
        <div class="easyui-panel " title="按钮区域" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <div style="margin:15px 0px">
              <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.StockReturnApplyBill()">退库申请</a>
              <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.StockReturnApplyBillReturn()">退库撤销</a>
            </div>
      </div>
      </div>
      <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
     
</body>
</html>

<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script>
/*
创建人：longb
日期：2023-01-06
描述：退库申请单-查看js
*/
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        editIndex: null,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/StockReturnApplyBillHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        //页面事件绑定
        bind: function () {
            $('#checkStatus').combobox({
                data: [{ id: '0', text: '待检验' }, { id: '1', text: '已检验' }, { id: '', text: '全部'}],
                valueField: 'id',
                textField: 'text',
                value: '',
                panelHeight:'auto'
            });
            $('#STATUS').combobox({
                data: [{ id: '1', text: '待确认' }, { id: '2', text: '已提交' }, { id: '', text: '全部'}],
                valueField: 'id',
                textField: 'text',
                value: '',
                panelHeight:'auto'
            });
             $('#ReturnType').combobox({
                    data:[{id:1,text:'退料入库'},{id:2,text:'退库入库'},{ id: '', text: '全部'}],
                    valueField:'id',
                    textField:'text',
                    value:1,
                    panelHeight:'auto'
                    });
            $('#StockReturnApplyTable').datagrid({
                checkOnSelect: false,
                selectOnCheck: false,
                singleSelect: true,
                rownumbers: true,
                nowrap: false,
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                frozenColumns: [[
                 { field: 'STOCKRETURNAPPLYBILLID', width: 120, checkbox: true },
                 { field: 'MFGORDERNAME', title: '订单号', width: 120 },
                 { field: 'PRODUCTNAME', title: '物料编码', width: 120 },
                 { field: 'DESCRIPTION', title: '物料名称', width: 100 },
                 { field: 'PRODUCTBATCHNO', title: '批次序列号', width: 120 },
                 { field: 'STOCKRETURNTYPE', title: '退库类型', width: 70, formatter: function (value, row, index) {if(value=="1"){return'退料入库';}else{return'退库入库';}} },
            ]],
                columns: [[
                 { field: 'INSTORELOCATION', title: '库存地点', width: 120 },
                 { field: 'STOCKRETURNREASON', title: '退库原因', width: 200 },
		         { field: 'STOCKRETURNNUM', title: '退库数量', width: 100 }, //--
                 { field: 'ACCEPTANCEQTY', title: '检验合格数', width: 100 }, //--
                 { field: 'WAREHOUSECODE', title: '仓库代码', width: 150},
                 { field: 'CHECKSTATUS', title: '检验状态', width: 100,formatter:function(value,row,index){if(value==1){return"已检验";}else{return"待检验";}} },
                 { field: 'STATUS', title: '状态', width: 100,formatter:function(value,row,index){if(value==1){return"待确认";}else if(value==2){return"已提交";}else if(value==3){return"已完成";}else{return"新创建";}}},
                 { field: 'CREATEDATENAME', title: '创建人', width: 100 },
                 { field: 'CREATEDATE', title: '创建时间', width: 150 },
                 { field: 'SUBMITNAME', title: '提交人', width: 100 },
                 { field: 'SUBMITDATE', title: '提交时间', width: 150 }
	           ]],
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.getStockReturnApplyData();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.getStockReturnApplyData();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.reset(true, true);
                page.pageNumber = 1; page.pagetotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pagetotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            });
        },

        //查询
        searchData: function () {
            page.reset(false, true);
            page.pageNumber = 1;
            page.getStockReturnApplyData();
            $('#EditorForm').form("clear");
        },
        //查询退库申请单信息
        getStockReturnApplyData: function () {
            var frdata = $('#searchForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            var param = {
                action: "getStockReturnApplyDataByPageSize",
                pageSize: page.pageSize,
                pageNumber: page.pageNumber,
                data: JSON.stringify(data)
            };
            page.post(param, function (res) {
                if (res.Result) {
                    //console.info(res);
                    page.pagetotal = res.RowCount;
                    $('#StockReturnApplyTable').datagrid('loadData', res.DBTable);
                }
            });
        },
        //退库申请
        StockReturnApplyBill: function () {
            var rows=$('#StockReturnApplyTable').datagrid('getChecked');
            var data=[];
            $.each(rows,function(index,item){
                if(item.CHECKSTATUS=="1"&&item.STATUS==1){
                    data.push(item);
                }
            });
            if(data.length==0){displayMessage("请选择至少一条【已检验】【待确认】退库申请单信息，再进行操作",false);return;}
             page.post({action:'updateStockReturnBillData',data:JSON.stringify(data),type:'confirm'}, function (res) {
                if (res.Result) {
                    page.getStockReturnApplyData();
                }
                displayMessage(res.Message, res.Result);
            });
        },
          //撤销（退回）申请
        StockReturnApplyBillReturn: function () {
            var rows=$('#StockReturnApplyTable').datagrid('getChecked');
            var data=[];
            $.each(rows,function(index,item){
                if(item.STATUS==2){
                    data.push(item);
                }
            });
            if(data.length==0){displayMessage("请选择至少一条【已提交】退库申请单信息，再进行操作",false);return;}
             page.post({action:'updateStockReturnBillData',data:JSON.stringify(data),type:'return'}, function (res) {
                if (res.Result) {
                    page.getStockReturnApplyData();
                }
                displayMessage(res.Message, res.Result);
            });
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
            $('#StockReturnApplyTable').datagrid('loadData',[]);
            //page.bind();
        },

        //清除方法，重要！！！
        reset: function (iscondition, isresult) {
            clearMessage();
        },
        //post数据
        post: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    }
$(function () {
    page.init();
});
</script>

